package net.sf.calibur.client;

import static java.lang.System.*;
import static java.lang.String.*;

import java.io.PrintStream;

public class ConsoleLogger implements Logger {

	@Override
	public void trace(String msg) {
		trace(msg, null);
		
	}

	@Override
	public void debug(String msg) {
		debug(msg, null);
		
	}

	@Override
	public void info(String msg) {
		info(msg, null);
		
	}

	@Override
	public void warn(String msg) {
		warn(msg, null);
		
	}

	@Override
	public void error(String msg) {
		error(msg, null);
		
	}
	
	private void print(PrintStream ps, String tag, String msg, Throwable t) {
		ps.println(format("[%5s] %s", tag, msg));
		if (t != null) {
			t.printStackTrace(ps);
		}
	}

	@Override
	public void trace(String msg, Throwable t) {
		print(out, "TRACE", msg, t);
		
	}

	@Override
	public void debug(String msg, Throwable t) {
		print(out, "DEBUG", msg, t);
		
	}

	@Override
	public void info(String msg, Throwable t) {
		print(out, "INFO", msg, t);
		
	}

	@Override
	public void warn(String msg, Throwable t) {
		print(out, "WARN", msg, t);
		
	}

	@Override
	public void error(String msg, Throwable t) {
		print(err, "ERROR", msg, t);
		
	}

}
